package com.lyj.cloud.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.dozer.DozerBeanMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lyj.cloud.api.CommonService;
import com.lyj.cloud.entity.Organization;
import com.lyj.cloud.service.EmployeeService;
import com.lyj.cloud.service.OrganizationService;

@RestController
public class SpringCloudServiceController implements CommonService<com.lyj.cloud.dto.Organization>{

	@Resource(name = "beanMapper")
	protected DozerBeanMapper beanMapper;
	@Resource
	private OrganizationService organizationService;
	@Resource
	private EmployeeService employeeService;
	
	@RequestMapping({"","/list"})
	public List<com.lyj.cloud.dto.Organization> list() {
		List<Organization> list = organizationService.findAll() ;
		List<com.lyj.cloud.dto.Organization> rtnList = new ArrayList<>(list.size());
		list.stream().forEach(org -> {
			com.lyj.cloud.dto.Organization target = new com.lyj.cloud.dto.Organization();
			beanMapper.map(org, target);
			rtnList.add(target);
		});
		return rtnList;
	}

}
